home *** CD-ROM | disk | FTP | other *** search
- Path: news.sprintlink.net!datalytics!usenet
- From: Rob Stewart <stew@datalytics.com>
- Newsgroups: comp.lang.c++
- Subject: Re: template classes in dll? (VC++ 4.0)
- Date: Fri, 22 Mar 1996 10:47:12 -0500
- Organization: Datalytics, Inc
- Message-ID: <3152CB80.4106@datalytics.com>
- References: <1996Mar6.133456.3709@cs.mun.ca> <313E48F6.41C67EA6@sparky.hampshire.ma.us> <4iim7m$ime@news2.ios.com>
- NNTP-Posting-Host: 204.62.224.71
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (WinNT; I)
-
- Vlastimil Adamovsky wrote:
- >
- > Scott Reed <scott@sparky.hampshire.ma.us> wrote:
- >
- > >I'm having difficulty building a VC++ 4.0 dll with template classes.
- > >The way I'm using the DllExport spec (actually __declspec(dllexport))
- > >doesn't appear to fit the syntax for template classes, i.e.
- > > template <class T> class DllExport ListOf {...};
- > >results in a syntax error ("error C2960: template 'class' requires a
- > >tag-name"). I've searched the online help for hours but I can't figure
- > >this out. I'd really appreciate any help on this.
- > > - scott
- >
- > If you really insist on using templates, then try to instantaite them
- > in the your DLL and then you should not get any problems using it.
- >
-
- To instantiate a template requires the complete source code.
- Thus, if a user of your DLL needs a specialization that is not
- otherwise present in your DLL, they will require the source
- code; the source is not exported.
-
- If you want to make specific instantiations part of your DLL,
- then you'll need to instantiate the template for specific
- template parameters and export them. I'm not certain how to do
- that in VC, but there is probably help or a KB article
- explaining how to do it. Even doing this, someone may wish to
- instantiate your template for some other template parameters.
- Therefore, you'll need to provide the complete source code
- anyway.
-
- If you don't intend to make specific instantiations part of your
- DLL, then there is nothing to export. You just have to
- distribute the complete template source code with your DLL.
-
- Either way, the source code is visible--the one drawback to
- templates.
-
- --
- Robert Stewart | My opinions are usually my own.
- Datalytics, Inc. | stew@datalytics.com
-